using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace Easy.Geo.Kml
{
    public class LineString : Geometry
    {
        private StringBuilder _text = new StringBuilder();        

        public LineString() 
            : base() 
        {
            this._coordinates = new Coordinate[] { };
        }
        public LineString(Coordinate[] coordinates):this()
        {                        
            this._SetCordinates(coordinates);
        }

        private Coordinate[] _coordinates;
        [XmlIgnore()]
        public Coordinate[] Coordinates
        {
            get { return this._coordinates; }
            set { this._coordinates = value; }
        }
          
        [XmlElement(ElementName="coordinates")]
        public string Text
        {
            get
            {
                return this._text.ToString();
            }
            set
            {
            }
        }
        
        public void AddCoordinate(Coordinate coordinate)
        {
            this._text.AppendLine(coordinate.ToString());
        }

        private void _SetCordinates(Coordinate[] coordinates)
        {
            foreach (Coordinate c in coordinates)
            {
                this.AddCoordinate(c);
            }
            this._coordinates = coordinates;
        }
    }
}
